package com.kdweibo.demo.activities;

import kdweibo4j.Configuration;
import kdweibo4j.Weibo;
import kdweibo4j.http.AccessToken;
import kdweibo4j.http.RequestToken;

public class AuthConstant {
	public static final String TAG = "kingdee_weibo";
	public static final String DATE_FORMAT_STATUS_VIEW = "MM-dd HH:mm";
	public String authType = "XAUTH"; //登录认证类型，默认为OAuth或XAuth
	public static String AUTH_TYPE_BASE = "BASE";
	public static String AUTH_TYPE_XAUTH = "XAUTH";
	public static String AUTH_TYPE_OAUTH = "OAUTH";
	private static Weibo weibo=null;
	private static AuthConstant instance=null;
	private RequestToken requestToken;
	private AccessToken accessToken;
	private String token;
	private String tokenSecret;
	
	private AuthConstant(){};
	public static synchronized AuthConstant getInstance(){
		if(instance==null)
			instance= new AuthConstant();
		return instance;
	}
	public Weibo getWeibo(){
		if(weibo==null){
			if(AUTH_TYPE_BASE.equals(this.authType)){
				weibo= new Weibo(Configuration.getProperty("weibo4j.user"), Configuration.getProperty("weibo4j.password"));
			}else{
				weibo= new Weibo();
			}
		}
		return weibo;
	}
	
	public AccessToken getAccessToken() {
		return accessToken;
	}
	public void setAccessToken(AccessToken accessToken) {
		this.accessToken = accessToken;
		this.token=accessToken.getToken();
		this.tokenSecret=accessToken.getTokenSecret();
	}
	public RequestToken getRequestToken() {
		return requestToken;
	}
	public void setRequestToken(RequestToken requestToken) {
		this.requestToken = requestToken;
	}
	public String getToken() {
		return token;
	}
	public void setToken(String token) {
		this.token = token;
	}
	public String getTokenSecret() {
		return tokenSecret;
	}
	public void setTokenSecret(String tokenSecret) {
		this.tokenSecret = tokenSecret;
	}
	
}
